package com.rcadmin.busi.publish.action;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.rcadmin.busi.publish.dto.PublishOnlineReq;
import com.rcadmin.busi.publish.service.PublishService;
import com.rcadmin.core.app.action.ResponseData;
import com.rcadmin.core.app.action.ResponseUtils;
import com.rcadmin.core.web.BaseAction;

/**
 * 
 * @author tanson lam
 * @create 2016年10月28日
 */

@RestController
public class PublishRest extends BaseAction {
	@Resource
	private PublishService publishService;

	/**
	 * 保存
	 */
	@RequestMapping(value = "/publish/online.op", method = RequestMethod.POST)
	@ResponseBody
	public ResponseData online(@RequestBody PublishOnlineReq publishOnlineReq) {
		ResponseData responseData = null;
		String failMes = "发布失败！";
		try {
			publishService.publishOnline(getLoginUserId(),
					publishOnlineReq.getTemplatePackageId());
			responseData = ResponseUtils.success("发布成功！");
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			responseData = ResponseUtils.fail(failMes);
		}
		return responseData;
	}
}
